package com.mingqijia.gassafety.console.controller;

import com.gap.basic.base.CommonResponse;
import com.mingqijia.gassafety.db.entity.Feedback;
import com.mingqijia.gassafety.webserver.request.FeedbackRequest;
import com.mingqijia.gassafety.webserver.response.FeedBackAllResponse;
import com.mingqijia.gassafety.webserver.service.FeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@RestController
@Api(tags = "意见反馈")
@RequestMapping("/business/v1/feedback")
public class FeedbackController {

    @Autowired
    FeedbackService feedbackService;

    @ApiOperation(value = "获取意见反馈列表")
    @PostMapping("/list")
    public CommonResponse<Object> getList(@RequestBody FeedbackRequest request) {
        return CommonResponse.success(feedbackService.getFeedbackList(request));
    }

    @ApiOperation(value = "添加意见反馈")
    @PostMapping("/add")
    public CommonResponse<Object> add(@RequestBody @Validated FeedbackRequest request) {
        boolean flag = feedbackService.add(request);
        return CommonResponse.success(flag);
    }

    @ApiOperation(value = "回复")
    @PostMapping("/reply")
    public CommonResponse<Object> reply(@RequestBody FeedbackRequest request) {
        boolean flag = feedbackService.reply(request);
        return CommonResponse.success(flag);
    }

    @ApiOperation(value = "查看状态")
    @PostMapping("/getCheckStatus")
    public CommonResponse<Object> getCheckStatus() {
        boolean status = feedbackService.getCheckStatus();
        return CommonResponse.success(status);
    }

    @ApiOperation(value = "查看状态编辑")
    @PostMapping("/checkStatus/edit")
    public CommonResponse<Object> editCheckStatus() {
        feedbackService.editCheckStatus();
        return CommonResponse.success("修改查看状态成功");
    }

    @ApiOperation(value = "处理数量汇总")
    @PostMapping("/numer")
    public CommonResponse<Object> aggregation() {
        FeedBackAllResponse response =  feedbackService.aggregation();
        return CommonResponse.success(response);
    }


}
